package com.angel.architecture.daos.impl;

import java.util.List;

import com.angel.architecture.constants.ArchitectureConfigurationParametersNames;
import com.angel.architecture.daos.ConfigurationParameterDAO;
import com.angel.architecture.persistence.beans.ConfigurationParameter;
import com.angel.architecture.persistence.ids.ObjectId;
import com.angel.dao.generic.impl.GenericSpringHibernateDAO;

public class ConfigurationParameterSpringHibernateDAO extends GenericSpringHibernateDAO<ConfigurationParameter, ObjectId> implements ConfigurationParameterDAO{

    public ConfigurationParameterSpringHibernateDAO(){
        super(ConfigurationParameter.class, ObjectId.class);
    }

    public List<ConfigurationParameter> findAllByDescription(String description){
        return (List<ConfigurationParameter>) this.findAll("description", description);
	}

    public ConfigurationParameter findUniqueByName(String name) {
        return this.findUnique("name", name);
    }

    public boolean findAllowLogErrorMessages(){
        ConfigurationParameter configurationParameter = super.findUniqueOrNull("name", ArchitectureConfigurationParametersNames.ALLOW_LOG_ERROR_MESSAGES_CONFIGURATION_PARAMETER);
        boolean alloErrorMessage = false;
        if(configurationParameter != null){
            alloErrorMessage = configurationParameter.getBooleanValue();
        }
        return alloErrorMessage;
    }

	public ConfigurationParameter findUniqueOrNullByName(String name) {
		return super.findUniqueOrNull("name", name);
	}
}